﻿@using InnovaApp.Layers.ResourcesLayer.Properties
@model INNOVACALL.Framework.Common.Models.ViewModels.MetaModels.LayoutMenus.LayoutMenu_Translation_MetaModel
<li><a href="@Model.DirectURL" class="@Model.CssClass" title="@Model.ButtonToolTip">@(Model.DefaultAction != "CreateMenu" ? (Model.AdminMode ? Html.Raw("&nbsp;&nbsp;") : Html.Raw("")) : Html.Raw(""))@Model.ButtonCaption@(Model.DefaultAction != "CreateMenu" ? (Model.AdminMode ? Html.Raw("&nbsp;&nbsp;") : Html.Raw("")) : Html.Raw(""))</a>
    @*
    Menu bar move buttons :
    First can't move
    Second ca move right if it's not the last one
    Second can't move left
    Last can't move right
    *@
    @if (Model.AdminMode && Model.CssClass == "MenuBarItem" && Model.DefaultAction != "CreateMenu" && Model.LayoutMenuTranslationLayoutMenuParent == null && Model.SortIndex > 1)
    {
        if ((Model.CssClass == "MenuBarItem" && Model.SortIndex > 2 && Model.SortIndex <= Model.LevelCount))
        { 
        <div class="AdminModeMenuButtonLeft AdminModeMenuButtonTop ui-icon ui-icon-circle-triangle-w Reorder" 
            title="@Resources.View_All_MenuMoveLeft_Title"
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL"
            data-id="@Model.Id" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.LayoutMenuTranslationLayoutMenuParent == 0 ? "" : Model.LayoutMenuTranslationLayoutMenuParent.ToString())"
            data-value="-1"
        >
        </div>
        }
        if (Model.SortIndex < Model.LevelCount)
        { 
        <div class="AdminModeMenuButtonLeft AdminModeMenuButtonBottom ui-icon ui-icon-circle-triangle-e Reorder" 
            title="@Resources.View_All_MenuMoveRight_Title"
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL"
            data-id="@Model.Id" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.LayoutMenuTranslationLayoutMenuParent == 0 ? "" : Model.LayoutMenuTranslationLayoutMenuParent.ToString())"
            data-value="1"
        >
        </div>
        }
    }
@*
    Drop down menu move buttons :
    The first one can move down if it's not alone
    The first one can't mobe up
    The last one can move up
    The last one can't move down
    *@
    else if (Model.AdminMode && Model.CssClass == "MenuElementItem" && Model.LevelCount > 1)
    {
        if (Model.SortIndex > 1)
        { 
        <div class="AdminModeMenuButtonLeft AdminModeMenuButtonTop ui-icon ui-icon ui-icon-circle-triangle-n Reorder" 
            title="@Resources.View_All_MenuMoveUp_Title"
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL"
            data-id="@Model.Id" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.LayoutMenuTranslationLayoutMenuParent == 0 ? "" : Model.LayoutMenuTranslationLayoutMenuParent.ToString())"
            data-value="-1"
        >
        </div>
        }
        if (Model.SortIndex < Model.LevelCount)
        { 
        <div class="AdminModeMenuButtonLeft AdminModeMenuButtonBottom ui-icon ui-icon ui-icon-circle-triangle-s Reorder" 
            title="@Resources.View_All_MenuMoveDown_Title"
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL"
            data-id="@Model.Id" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.LayoutMenuTranslationLayoutMenuParent == 0 ? "" : Model.LayoutMenuTranslationLayoutMenuParent.ToString())"
            data-value="1"
        >
        </div>
        }
    }
    @if (Model.SubMenus.Count > 0)
    {
@*        <span title="@Model.ButtonToolTip" class="@Model.CssClass">@(Model.DefaultAction != "CreateMenu" ? (Model.AdminMode ? Html.Raw("&nbsp;&nbsp;") : Html.Raw("")) : Html.Raw(""))@Model.ButtonCaption</span>
*@        <ul>
    @foreach (var subMenu in Model.SubMenus)
    {
        @Html.Partial("_MenuElement", subMenu)
    }
        </ul>
    if (Model.AdminMode && Model.Id > 2)
    {
        <div class="AdminModeMenuButtonRight AdminModeMenuButtonBottom ui-icon ui-icon-circle-plus AddMenuItem" 
            title="@Resources.View_All_MenuAddSubItem_Title" 
            data-id="-1"
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL" @*ParentDirectURL*@
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.FK_LayoutMenu == null ? "" : Model.FK_LayoutMenu.ToString())"
            >
        </div>
    }
    }
    else
    {

        if (Model.AdminMode && Model.DefaultAction != "CreateMenu" || (Model.CssClass == "MenuBarItem" && Model.DefaultAction == "CreateMenu"))
        {
            if (Model.Id > 2)
            { 
        <div class="AdminModeMenuButtonRight AdminModeMenuButtonTop ui-icon ui-icon-circle-close RemoveMenuItem"
            title="@Resources.View_All_MenuRemoveItem_Title"
            data-id="@Model.Id" 
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.LayoutMenuTranslationLayoutMenuParent == 0 ? "" : Model.LayoutMenuTranslationLayoutMenuParent.ToString())"
            >
        </div>
            }
            if (Model.Id == -1)
            {
        <div class="AdminModeMenuButtonRight AdminModeMenuButtonBottom ui-icon ui-icon-circle-plus AddMenuItem LastMenuBarItem"
            title="@Model.ButtonToolTip" 
            data-id="-1" 
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.FK_LayoutMenu == null ? "" : Model.FK_LayoutMenu.ToString())"
            >
        </div>
            }
            else if (Model.Id > 2)
            {
        <div class="AdminModeMenuButtonRight AdminModeMenuButtonBottom ui-icon ui-icon-circle-plus AddMenuItem"
            title="@Resources.View_All_MenuAddSubItem_Title" 
            data-id="-1" 
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.FK_LayoutMenu == null ? "" : Model.FK_LayoutMenu.ToString())"
            >
        </div>
            }
        }
    }
    @if (Model.AdminMode && Model.Id > -1)
    { 
        <div class="AdminModeMenuToggleActivation @(Model.Active ? "AdminModeMenuToggleActivationOn" : "AdminModeMenuToggleActivationOff")" title="@Resources.View_All_MenuItemActivator_Title" 
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL"
            data-id="@Model.Id" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.LayoutMenuTranslationLayoutMenuParent == 0 ? "" : Model.LayoutMenuTranslationLayoutMenuParent.ToString())"
            data-Ancestors="@Model.Ancestors"
        >
        </div>
        <div class="EditMenuItem" title="@Resources.View_All_MenuEditor_Title" 
            data-language="@Model.Language.Language" 
            data-DirectURL="@Model.DirectURL"
            data-id="@Model.Id" 
            data-LayoutMenuTranslationLayoutMenuParent="@(Model.LayoutMenuTranslationLayoutMenuParent == 0 ? "" : Model.LayoutMenuTranslationLayoutMenuParent.ToString())"
            data-Ancestors="@Model.Ancestors"
        >
        </div>
    }
</li>
